package sword.T57;

/**
 * @Author: 18362
 * @Create: 2022-04-10 12:53:21 星期日
 */
class Solution {
    public int[] twoSum(int[] nums, int target) {
        int left = 0, right = nums.length-1;
        while (left < right) {
            int sum = nums[left] + nums[right];
            if (sum == target)
                return new int[] {nums[left], nums[right]};
            else if (sum < target)
                left++;
            else
                right--;
        }
        return new int[]{};
    }
}